import os
import hashlib
from typing import List

# 从环境变量读取权威节点列表，用逗号分隔
AUTHORITY_NODES: List[str] = os.getenv("AUTHORITY_NODES", "node1,node2").split(",")

def verify_authority(node_id: str) -> bool:
    """判断节点是否为权威节点"""
    return node_id in AUTHORITY_NODES

def poa_seal(block_hash: str, private_key: str) -> str:
    """简单 PoA 签名：hash(block_hash + private_key) 前 16 位"""
    return hashlib.sha256(f"{block_hash}{private_key}".encode()).hexdigest()[:16]